let express = require('express');

let router = express.Router();

let login = require('./admin/login');

let product = require('./admin/product');

router.use((req,res,next)=>{
    console.log(req.url);
    if(req.url == '/login' || req.url == '/login/doLogin'){
        next();
    }else{
        if(req.session.userInfo && req.session.userInfo.username){
            req.app.locals['userInfo'] = req.session.userInfo;//配置全局变量，可以在任何模板页面中使用
            next();
        }else{
            res.redirect('/admin/login');
        }
    }
});
router.use('/login',login);
router.use('/product',product);


module.exports = router;